home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.awt.Button; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Event; import java.awt.FileDialog; import java.awt.Font; import java.awt.Frame; import java.awt.Label; import java.awt.LayoutManager; import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; import java.awt.Rectangle; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FilterInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import symantec.itools.awt.WrappingLabel; import symantec.itools.multimedia.ImageViewer; import symantec.itools.multimedia.SlideShow; import symantec.itools.net.RelativeURL; public class AmazingTour extends Frame { int dayCount; String fileName; Rectangle slideShowBounds; FileDialog openFileDialog1; WrappingLabel wrappingLabelStart; Label labelDay; WrappingLabel wrappingLabelPeople; SlideShow slideShowItinerary; WrappingLabel wrappingLabelDesc; ImageViewer imageViewerLogo; Button buttonPrevious; Button buttonNext; WrappingLabel wrappingLabelTop; MenuBar mainMenuBar; Menu menu1; Menu menu3; void slideShowItinerary_SlideChanged(Event event) { this.buttonNext.enable(!this.slideShowItinerary.isAtLastImage()); this.buttonPrevious.enable(!this.slideShowItinerary.isAtFirstImage()); this.wrappingLabelDesc.setText(this.slideShowItinerary.getDescription(this.slideShowItinerary.getCurrentImageIndex())); } void buttonNext_Clicked(Event event) { this.slideShowItinerary.nextImage(); this.labelDay.setText("Day " + ++this.dayCount); } void buttonPrevious_Clicked(Event event) { this.slideShowItinerary.previousImage(); this.labelDay.setText("Day " + --this.dayCount); } void Open_Action(Event event) { this.openFileDialog1.show(); String tempFileName = this.openFileDialog1.getDirectory() + this.openFileDialog1.getFile(); if ((this.fileName != null || tempFileName.endsWith(".dat")) && tempFileName.endsWith(".dat")) { if (this.fileName == null) { this.wrappingLabelStart.hide(); } this.fileName = tempFileName; if (this.slideShowItinerary != null) { ((Container)this).remove(this.slideShowItinerary); } this.dayCount = 1; this.slideShowItinerary = new SlideShow(); this.slideShowItinerary.reshape(((Container)this).insets().left + this.slideShowBounds.x, ((Container)this).insets().top + this.slideShowBounds.y, this.slideShowBounds.width, this.slideShowBounds.height); ((Container)this).add(this.slideShowItinerary); this.getEntries(this.openFileDialog1.getDirectory(), this.fileName); this.buttonNext.show(); this.buttonPrevious.show(); this.wrappingLabelTop.setText("Custom Itinerary for"); this.labelDay.setText("Day " + this.dayCount); this.wrappingLabelDesc.setText(this.slideShowItinerary.getDescription(this.slideShowItinerary.getCurrentImageIndex())); this.buttonPrevious.disable(); if (this.slideShowItinerary.isAtLastImage()) { this.buttonNext.disable(); } else { this.buttonNext.enable(); } } } void About_Action(Event event) { (new AboutDialog(this, true)).show(); } void Exit_Action(Event event) { (new QuitDialog(this, true)).show(); } public AmazingTour() { this.dayCount = 1; new AboutDialog(this, true); new QuitDialog(this, true); ((Container)this).setLayout((LayoutManager)null); ((Frame)this).addNotify(); ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 595, ((Container)this).insets().top + ((Container)this).insets().bottom + 550); ((Component)this).setFont(new Font("Dialog", 1, 12)); ((Component)this).setForeground(new Color(0)); ((Component)this).setBackground(new Color(16777215)); this.openFileDialog1 = new FileDialog(this, "Open", 0); this.wrappingLabelStart = new WrappingLabel(); this.wrappingLabelStart.reshape(((Container)this).insets().left + 8, ((Container)this).insets().top + 24, 225, 132); this.wrappingLabelStart.setFont(new Font("Dialog", 1, 16)); ((Container)this).add(this.wrappingLabelStart); this.wrappingLabelStart.setAlignStyle(0); this.wrappingLabelStart.setText("To start, choose Open from the File menu and open your data file. Your .dat file and the graphics files must be in the same directory."); this.labelDay = new Label("", 1); this.labelDay.reshape(((Container)this).insets().left + 72, ((Container)this).insets().top + 208, 86, 26); this.labelDay.setFont(new Font("Dialog", 2, 16)); ((Container)this).add(this.labelDay); this.wrappingLabelPeople = new WrappingLabel(); this.wrappingLabelPeople.reshape(((Container)this).insets().left + 8, ((Container)this).insets().top + 88, 232, 88); this.wrappingLabelPeople.setFont(new Font("Dialog", 1, 24)); ((Container)this).add(this.wrappingLabelPeople); this.wrappingLabelPeople.setAlignStyle(1); this.wrappingLabelPeople.setText(""); this.slideShowItinerary = new SlideShow(); this.slideShowItinerary.reshape(((Container)this).insets().left + 251, ((Container)this).insets().top + 219, 340, 235); ((Container)this).add(this.slideShowItinerary); this.wrappingLabelDesc = new WrappingLabel(); this.wrappingLabelDesc.reshape(((Container)this).insets().left + 16, ((Container)this).insets().top + 248, 224, 272); this.wrappingLabelDesc.setFont(new Font("Dialog", 0, 14)); ((Container)this).add(this.wrappingLabelDesc); this.wrappingLabelDesc.setAlignStyle(0); this.wrappingLabelDesc.setText(""); this.imageViewerLogo = new ImageViewer(); this.imageViewerLogo.reshape(((Container)this).insets().left + 256, ((Container)this).insets().top + 16, 320, 217); ((Container)this).add(this.imageViewerLogo); try { this.imageViewerLogo.setURL(RelativeURL.getURL("Images/Logo.gif")); } catch (MalformedURLException var1) { } this.buttonPrevious = new Button("Previous"); this.buttonPrevious.hide(); this.buttonPrevious.reshape(((Container)this).insets().left + 336, ((Container)this).insets().top + 496, 82, 25); ((Container)this).add(this.buttonPrevious); this.buttonNext = new Button("Next"); this.buttonNext.hide(); this.buttonNext.reshape(((Container)this).insets().left + 424, ((Container)this).insets().top + 496, 82, 25); ((Container)this).add(this.buttonNext); this.wrappingLabelTop = new WrappingLabel(); this.wrappingLabelTop.reshape(((Container)this).insets().left + 8, ((Container)this).insets().top + 40, 232, 38); this.wrappingLabelTop.setFont(new Font("Dialog", 1, 16)); ((Container)this).add(this.wrappingLabelTop); this.wrappingLabelTop.setAlignStyle(1); this.wrappingLabelTop.setText(""); ((Frame)this).setTitle("Amazing Adventures Travel - Custom Itinerary Application"); this.slideShowBounds = this.slideShowItinerary.bounds(); this.mainMenuBar = new MenuBar(); this.menu1 = new Menu("File"); this.menu1.add("Open..."); this.menu1.addSeparator(); this.menu1.add("Exit"); this.mainMenuBar.add(this.menu1); this.menu3 = new Menu("Help"); this.mainMenuBar.setHelpMenu(this.menu3); this.menu3.add("About"); this.mainMenuBar.add(this.menu3); ((Frame)this).setMenuBar(this.mainMenuBar); } public AmazingTour(String title) { this(); ((Frame)this).setTitle(title); } public synchronized void show() { ((Component)this).move(50, 50); super.show(); } public boolean handleEvent(Event event) { if (event.target == this.buttonPrevious && event.id == 1001) { this.buttonPrevious_Clicked(event); } if (event.target == this.buttonNext && event.id == 1001) { this.buttonNext_Clicked(event); } if (event.target == this.slideShowItinerary && event.id == 1001) { this.slideShowItinerary_SlideChanged(event); } if (event.id == 201) { ((Component)this).hide(); ((Frame)this).dispose(); System.exit(0); return true; } else { return super.handleEvent(event); } } public boolean action(Event event, Object arg) { if (event.target instanceof MenuItem) { String label = (String)arg; if (label.equalsIgnoreCase("Open...")) { this.Open_Action(event); return true; } if (label.equalsIgnoreCase("About")) { this.About_Action(event); return true; } if (label.equalsIgnoreCase("Exit")) { this.Exit_Action(event); return true; } } return super.action(event, arg); } public static void main(String[] args) { (new AmazingTour()).show(); } private void getEntries(String dir, String filename) { try { DataInputStream in = new DataInputStream(new FileInputStream(filename)); this.wrappingLabelPeople.setText(in.readLine()); int numEntries = Integer.parseInt(in.readLine()); dir = "file:/" + dir.substring(0, dir.lastIndexOf(92)); for(int i = 0; i < numEntries; ++i) { String s1 = dir + "/" + in.readLine(); String s2 = in.readLine(); this.slideShowItinerary.addImageAndDescription(new URL(s1), s2); } ((FilterInputStream)in).close(); ((Component)this).invalidate(); ((Container)this).validate(); } catch (FileNotFoundException var8) { System.err.println("Can't open " + filename); } catch (IOException var9) { System.err.println("Error reading " + filename); } } }